import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
//lock操作放在try外面
public class ThreadLock3 {
    public static void main(String[] args) {
        Lock lock=new ReentrantLock();
        lock.lock();
        try{
            System.out.println("进入了try方法");
            //某一种极端操作
            int i=10/0;
            System.out.println("执行lock操作");
        }finally{
            System.out.println("执行unlock操作");
            lock.unlock();
        }
    }
}
